import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { HttpProvider } from "../../providers/http/http";

import { DomSanitizer } from '@angular/platform-browser';//引入
/**
 * Generated class for the ArticlePage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-article',
  templateUrl: 'article.html',
})
export class ArticlePage {
  articleUrl:string = ''
  articleData:Object = {};
  constructor(public navCtrl: NavController, public navParams: NavParams,private httpProvider:HttpProvider, public sanitizer: DomSanitizer) {
    this.articleUrl = this.navParams.get('url');
    // this.articleUrl = 'http://api.yidian.mingyiteach.com/api/index/article?id=2575'
  }

  ionViewDidLoad() {
    console.log('ionViewDidLoad ArticlePage');
    //http://api.yidian.mingyiteach.com/api/index/article?id=2575
    console.log("url ==="+this.articleUrl);
    this.httpProvider.GET(this.articleUrl, (data)=>{
      this.articleData = data;
      console.log("data====="+JSON.stringify(this.articleData));
    }, (err)=>{

    });
  }

  assembleHTML() {
    return this.sanitizer.bypassSecurityTrustHtml(this.articleData['content']);
  }

}
